package com.offcn.bigdata.spark.p3

import org.apache.spark.broadcast.Broadcast
import org.apache.spark.{SparkConf, SparkContext}

import scala.collection.mutable.ArrayBuffer

/**
  * 广播变量操作
  */
object _02BroadcastOps {
    def main(args: Array[String]): Unit = {
        val conf = new SparkConf()
            .setMaster("local[*]")
            .setAppName(s"${_02BroadcastOps.getClass.getSimpleName}")
        val sc = new SparkContext(conf)

        val ab = new ArrayBuffer[Int]()
        val rdd = sc.parallelize(1 to 10)

        rdd.foreach(num => {
            ab.append(num)
            println(num)
        })

        println("-----------------------")
        println(ab)
        sc.stop()
    }
}
